package com.czk.index;

import com.czk.util.ClientUtil;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;

import java.io.IOException;

/**
 * @Author:ChenZhangKun
 * @Date: 2021/6/13 13:58
 */
public class DeleteIndex {
    public static void main(String[] args) throws IOException {
        // 拿客户端
        RestHighLevelClient highLevelClient = ClientUtil.getHighLevelClient();
        DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest("user");
        // 执行删除
        AcknowledgedResponse delete = highLevelClient.indices().delete(deleteIndexRequest, RequestOptions.DEFAULT);
        System.out.println(delete.isAcknowledged());
        // 关闭客户端
        highLevelClient.close();
    }
}
